package net.huashitong.scheduling.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import net.huashitong.scheduling.entity.IndicatorScheduling;
import net.huashitong.scheduling.filter.IndicatorSchedulingFilter;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.core.filter.BaseFilter;
import com.sirdc.modules.utils.ObjectUtils;

@Repository
public class IndicatorSchedulingDao extends StringDao<IndicatorScheduling> {

	public List<IndicatorScheduling> queryByCategory(
			IndicatorSchedulingFilter filter) {
		GenericQuery query = createQuery("obj");
		query.append(" and obj.indicatorsCategory = :indicatorsCategory").setParam("indicatorsCategory", filter.getIndicatorsCategory());
		if(ObjectUtils.isNotBlank(filter.getMonth())){
			query.append(" and obj.month = :month").setParam("month", filter.getMonth());
		}else{
			query.append(" and obj.month = :month").setParam("month", "06");
		}
		query.append(" and obj.year = :year order by cast(obj.sysId as int) ASC").setParam("year", filter.getYear());
		return query.listResult();
	}
	
	

}
